package org.dtrd.modules.evaluation.entity.bean.parq;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import org.dtrd.modules.evaluation.constant.Evaluation;
import org.dtrd.modules.evaluation.entity.po.DtrdEntEvaluationRdParq;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 
 * </p>
 *
 * @author xiao
 * @since 2022-08-15
 */
@Getter
@Setter
@ApiModel(value = "PARQ新增请求")
public class ParqDetail {

    private Integer dataId;

    @NotNull
    @ApiModelProperty(value = "患者ID", required = true)
    private Integer patientId;

    @NotEmpty
    @ApiModelProperty(value = "答案", required = true)
    private List<Integer> answers;

    public ParqDetail parseFromPo(DtrdEntEvaluationRdParq po) {
        this.dataId = po.getDataId();
        this.patientId = po.getPatientId();
        String input = po.getInput();
        String[] answerList = input.split(",");
        ArrayList<Integer> answers = new ArrayList<>(Evaluation.ProblemNum.PARQ.getNum());
        for (String s : answerList) {
            Integer answer = Integer.parseInt(s);
            answers.add(answer);
        }
        this.answers = answers;
        return this;
    }
}
